def calc(s1, s2):
    length = min(len(s1), len(s2))
    return max(range(length + 1), key=lambda i: i if s1[len(s1) - i::] == s2[:i:] else 0)


def solve():
    s1 = input()
    s2 = input()
    print(calc(s1, s2))


if __name__ == "__main__":
    solve()
